Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various alterations and additions to numeric methods #6301

Merged
merged 5 commits into from
May 8, 2013

Conversation

brendanzab
Copy link
Member

This is part of the redesign of the numeric traits tracked in issue #4819.

Renamed:

  • Exponential::expm1 -> Float::exp_m1 - for consistency with underscore usage elsewhere
  • Exponential::log -> Exponential::ln - a less ambiguous name for the natural logarithm
  • {float, f64, f32}::logarithm -> Exponential::log - for arbitrary base logarithms
  • Real::log_2 -> Real::ln_2 - for consistency with ln
  • Real::log_10 -> Real::ln_10 - for consistency with ln

Added:

  • Signed::abs_sub - wraps libm's fdim function
  • Float::is_normal - returns true if the number is neither zero, infinite, subnormal or NaN
  • Float::classify - returns the floating point category of the number
  • Float::ln_1p - returns the natural logarithm of the number plus one

Both expm1 and ln1p have been renamed to exp_m1 and ln_1p in order to be consistent with the underscore usage elsewhere.

The exp_m1 method is used for increased accuracy when doing floating point calculations, so this has been moved from the more general 'Exponential' trait into 'Float'.
}

/// Returns the floating point category of the number. If only one property is going to
/// be tested, it is generally faster to use the specific predicate instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that's true? At least if this method is inlined, I imagine the LLVM optimizer will be able to handle it well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're probably right. I'll remove this in a future commit.

bors added a commit that referenced this pull request May 7, 2013
This is part of the redesign of the numeric traits tracked in issue #4819.

Renamed:

- `Exponential::expm1` -> `Float::exp_m1` - for consistency with underscore usage elsewhere
- `Exponential::log` -> `Exponential::ln` - a less ambiguous name for the natural logarithm
- `{float, f64, f32}::logarithm` -> `Exponential::log` - for arbitrary base logarithms
- `Real::log_2` -> `Real::ln_2`  - for consistency with `ln`
- `Real::log_10` -> `Real::ln_10` - for consistency with `ln`

Added:

- `Signed::abs_sub` - wraps libm's `fdim` function
- `Float::is_normal` - returns `true` if the number is neither zero, infinite, subnormal or NaN
- `Float::classify` - returns the floating point category of the number
- `Float::ln_1p` - returns the natural logarithm of the number plus one
@bors bors closed this May 8, 2013
@bors bors merged commit cc51186 into rust-lang:incoming May 8, 2013
@brendanzab brendanzab deleted the numeric-traits branch May 8, 2013 00:37
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 20, 2020
do not trigger map_clone in the case of &mut

fixes rust-lang#6299
changelog: do not trigger map_clone in the case of &mut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants